﻿function trim(cadena) {
    return cadena.replace(/^\s+|\s+$/g, '');
};

function validaCorreo(campoEmail) {
    var re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
    return campoEmail.match(re) || campoEmail == "";
}
function validaUsuario(campoUser) {
    var re = /^[a-z][\w\.]{0,24}$/i;
    return campoUser.match(re) || campoUser == "";
}
function mostrarInfo(persona) {
    $('.infopersona').hide();
    if (persona != "persona")
        $('.opcionesPersona').hide();
    $('#info' + persona).show();
}
function mostrarOpcionesPersona() {
    mostrarInfo("persona");
    $('.opcionesPersona').show();
}

function validateNumber(evt) {
    var e = evt || window.event;
    var key = e.keyCode || e.which;

    if (!e.shiftKey && !e.altKey && !e.ctrlKey &&
        // numbers   
    (key >= 48 && key <= 57) ||
        // Numeric keypad
    (key >= 96 && key <= 105) ||
        // Backspace and Tab and Enter
    key == 8 || key == 9 || key == 13 ||
        // Home and End
    key == 35 || key == 36 ||
        // left and right arrows
    key == 37 || key == 39 ||
        // Del and Ins
    key == 46 || key == 45 ||
        // . and numeric pad .
	key == 190 || key == 110) {
        // input is VALID
    }
    else {
        // input is INVALID
        e.returnValue = false;
        if (e.preventDefault) e.preventDefault();
    }
}

